var app = getApp();

Page({
    data: {
        content: "",
        none: [ {
            img: "/hyb_jianzhi/images/none_03.png",
            con: "暂无管理员"
        } ],
        userList:[],
        page:1,
        choseicon:false,
        f_uid:''
    },
    onLoad: function(t) {

    },
    searchBlur: function(t) {
        if (console.log(t.detail.value), "" != t.detail.value) {
            var a = t.detail.value;
            this.setData({
                conB: a
            });
        }
    },
    subClick: function(t) {
        var a = this,keywords = t.detail.value.content;
        if(keywords !== ''){
            app.util.request({
            url: "entry/wxapp/Usersoso",
            data:{
               page: a.data.page,
               keyword:keywords, 
            },
            success: function(t) {
                a.setData({
                    userList: t.data.data
                });
            }
        });   
        }else{
         wx.showToast({
                title: "不能为空!",
                image: "/hyb_jianzhi/images/errors.png"
            })
        }
        
    },
    sort: function(t, a) {
        for (var e = 0; e < t.length; e++) if (a - t[e].juli < 0) {
            var i = t.splice(e, 1);
            t.push(i[0]);
        }
    },
    hdladdAdmin:function(e){
        var self = this,fuid = e.currentTarget.dataset.uid;
        self.setData({
            choseicon:!self.data.choseicon,
            f_uid:fuid
        })

    },
    addsure:function(){
        const self = this;
        if(self.data.f_uid !== ''){
           app.util.request({
            url: "entry/wxapp/ShopUseradd",
            data:{
               u_id: self.data.f_uid,
               openid: wx.getStorageSync("openid")
            },
            success: function(t) {
                if(t.data.data.isadmin == 0){
                    wx.showToast({
                      title: "添加成功"
                     });
                     self.setData({
                          userList:[]
                      });
             }else{
                wx.showToast({
                  title: "管理员已存在",
                  image: "/hyb_jianzhi/images/errors.png"
                 });
             }
            }
        })   
       }else{
        wx.showToast({
            title: "不能为空!",
            image: "/hyb_jianzhi/images/errors.png"
        });
       }
    },
    returnClick: function() {
        wx.reLaunch({
            url: "/hyb_jianzhi/index/index"
        });
    },
    onShareAppMessage: function() {}
});